FROM node:18-alpine3.14  AS dependencies

# 创建目录
RUN mkdir -p /home/app/

# 指定工作目录
WORKDIR /home/app/

# 将生产依赖和打包后的文件复制到指定目录下
COPY ./package.json ./package.json


RUN npm cache clean --force 

RUN npm config set  https://registry.npmmirror.com

RUN npm install --legacy-peer-deps --only=production 


FROM node:18-alpine3.14  AS release

# 创建目录
RUN mkdir -p /home/app/

# 指定工作目录
WORKDIR /home/app/

COPY --from=dependencies /home/app/node_modules ./node_modules

COPY ./dist ./dist

# 设置生产环境变量
ENV NODE_ENV production

# 启动服务
CMD node  ./dist/main.js

# 暴露端口
EXPOSE 10005
